<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>选择喜欢的</title>
  </head>
  <body>
    <div id="app">
      <h4>选择你喜欢的专栏</h4>
      <span v-for="(item,index) in list"
        ><input v-model="item.checked" type="checkbox" />{{item.name}}</span
      ><br />
      <br />
      <ul>
        <li v-for="item in newArr">{{item.name}}</li>
      </ul>
    </div>
    <script src="./vue.js"></script>
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          list: [
            { name: '科幻', checked: false },
            { name: '喜剧', checked: false },
            { name: '动漫', checked: false },
            { name: '冒险', checked: false },
            { name: '科技', checked: false },
            { name: '军事', checked: false },
            { name: '娱乐', checked: false },
            { name: '奇闻', checked: false }
          ]
        },
        computed: {
          newArr() {
            return this.list.filter(item => item.checked)
          }
        }
      })
    </script>
  </body>
</html>
